package com.ljf.authority.infra.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ljf.authority.domain.repository.AuthorityDatPermissionGroupRepository;
import com.ljf.authority.dto.query.AuthorityDatPermissionGroupQuery;
import com.ljf.authority.infra.mapper.AuthorityDatPermissionGroupMapper;
import com.ljf.authority.model.AuthorityDatPermissionGroup;
import com.ljf.authority.vo.AuthorityDatPermissionGroupVO;
import com.ljf.common.exception.ServiceException;
import com.ljf.common.infra.repository.impl.BasisRepositoryImpl;
import com.ljf.common.utils.CollectionUtil;
import com.ljf.common.utils.StringUtil;
import org.springframework.stereotype.Component;

/**
 * 权限组  数据访问接口实现
 *
 * @author LJF
 * @since 2024-10-30
 */
@Component
public class AuthorityDatPermissionGroupRepositoryImpl extends BasisRepositoryImpl<AuthorityDatPermissionGroupMapper, AuthorityDatPermissionGroup, AuthorityDatPermissionGroupQuery, AuthorityDatPermissionGroupVO> implements AuthorityDatPermissionGroupRepository {

    @Override
    protected QueryWrapper<AuthorityDatPermissionGroup> fillWrapper(AuthorityDatPermissionGroupQuery query, boolean sort) throws ServiceException {
        QueryWrapper<AuthorityDatPermissionGroup> wrapper = super.fillWrapper(query, sort);
        if (CollectionUtil.isNotEmpty(query.getCodeList())) {
            wrapper.in(AuthorityDatPermissionGroup.COL_CODE, query.getCodeList());
        }
        if (StringUtil.isNotEmpty(query.getNameLike())) {
            wrapper.like(AuthorityDatPermissionGroup.COL_NAME, query.getNameLike());
        }
        return wrapper;
    }

}
